<!--
 * @Descripttion: 
 * @version: 
 * @Author: jiating
 * @Date: 2021-02-22 17:03:48
 * @LastEditors: jiating
 * @LastEditTime: 2021-02-24 14:59:55
-->
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>K5G-C</title>
    <link rel="stylesheet" href="./css/common.css"/>
    <link rel="stylesheet" href="./css/index.css"/>
    <link rel="stylesheet" href="./css/mobile.css"/>
    <link rel="stylesheet" href="./css/modal.css">
</head>

<body>
<div class="main">
    <div class="tit-heade">
        <div class="itemOne">
            <img src="./image/left.png" >
        </div>
        <div class="itemTwo">
            <div class="item-chil">
                <img src="./image/logoutOne.png">
            </div>
            <div class="item-chil">
                <a href="/action/logout">ログアウト</a>
            </div>
            
        </div>
    </div> 
    <div class="nav2">
        <div class="nav-item">
            <div id='x1' class="item" onclick="toPage('./home.html')">ホーム</div>
        </div>
        <div class="nav-item">
            <div id='x2' class="item no-act" onclick="toPage('./mobileData.html')">モバイルネットワーク</div>
            <div class="">
                <div>
                    <div class="">
                        <div class="item1 choose" id="wifi1" onclick="toPage('./mobileData.html')">モバイルデータ設定</div>                    
                        <div class="item1" id="wifi_list" onclick="toPage('./priorityNetwork.html')">優先ネットワーク設定</div>
                        <div class="item1" id="wifi_list" onclick="toPage('./webSearch.html')">ネットワーク検索設定</div>
                        <div class="item1" id="wifi_list" onclick="toPage('./apn.html')">アクセスポイント設定</div>
                    </div>
                </div>
            </div>
        </div>
        <div class="nav-item">
            <div id='x3' class="item no-act" onclick="toPage('./wifi.html')">Wi-Fi設定</div>
        </div>
        <div class="nav-item">
            <div id='x4' class="item no-act" onclick="toPage('./dhcp.html')">Ethernet設定</div>
        </div>
        <div class="nav-item">
            <div id='x5' class="item no-act" onclick="toPage('./port.html')">LAN設定</div>
        </div>
        <div class="nav-itm">
            <div id='x6' class="item no-act" onclick="toPage('./password.html')">端末設定</div>
        </div>
    </div>

    <div id="mobile" class="content">
        <div class="title">モバイルデータ</div>

        <div style="margin-left: 100px;margin-top: 10px;">
            <p>モバイルデータのON/OFFを切り替えることができます。</p>
            <p>モバイルデータをOFFにすると、すべてのモバイルネットワークでデータ通信を利用しない設定となります。</p>
        </div>

        <div id="sim1">

            <div class="form-box" style="padding: 30px">
                <div style="color: #333333; font:bold; font-size: 24px; border-bottom: 1px solid #000">SIM1
                </div>
            </div>

            <form action="" class="default-form">
                <table class="input-table">
                    <tbody>
                    <tr>
                        <th><label class="default-label" for="">モバイルデータ</label></th>
                        <td>
                            <input type="checkbox" onclick="mobileData(0)" name="mobile-data0" id="mobile-data0"
                                class="chooseBtn"/>
                            <label for="mobile-data0" class="choose-label"/>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </form>
        </div>

        <div id="sim2">

            <div class="form-box" style="padding: 30px">
                <div style="color: #333333; font:bold; font-size: 24px; border-bottom: 1px solid #000">SIM2
                </div>
            </div>

            <form action="" class="default-form">
                <table class="input-table">
                    <tbody>
                    <tr>
                        <th><label class="default-label" for="">モバイルデータ</label></th>
                        <td>
                            <input type="checkbox" onclick="mobileData(1)" name="mobile-data1" id="mobile-data1"
                                class="chooseBtn"/>
                            <label for="mobile-data1" class="choose-label"/>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </form>

        </div>

    </div>
</div>

<script type="text/javascript" src="./js/utils.js"></script>
<script>

    window.onload = function () {
        getData()
        getSimNum()
    }

    function getSimNum() {
        var num = sessionStorage.getItem('activeSimNumber')
        if (num == 0) {
            var btn = document.getElementById('x2')
            btn.onclick = function() {}
            btn.style.backgroundColor = '#eee'
        }
        var params = {}
        Ajax.post(baseUrl + '/action/getActiveSimCardNumber', JSON.stringify(params), function(res) {
            var response = JSON.parse(res)
            if (response.status == 'success') {
                sessionStorage.setItem('activeSimNumber', response.data.activeSimNumber)
            }
        })
    }

    function getData(){
        var params = {}
        Ajax.post(baseUrl + '/action/getDataStatus', JSON.stringify(params), function (res) {
            var response = JSON.parse(res)
            if (response.status == 'success') {
                var data = response.data

                if(data.slot0 != 'null'){
                    document.getElementById("mobile-data0").checked = data.slot0 
                }else{
                    document.getElementById('sim1').style.display = "none"
                }

                if(data.slot1 != 'null'){
                    document.getElementById("mobile-data1").checked = data.slot1
                }else{
                    document.getElementById('sim2').style.display = "none"
                }

            } else {
                Message.showmsg(response.message)
            }
        })
    }

    function mobileData(data){
        var mobileDataStatus0 = document.getElementById("mobile-data0").checked;
        var mobileDataStatus1 = document.getElementById("mobile-data1").checked;
        if(data == 0){
            mobileDataStatus = mobileDataStatus0
        }
        if(data == 1){
            mobileDataStatus = mobileDataStatus1
        }
        var params = {
            slotId:data,
            enable: mobileDataStatus
        }
        Ajax.post(baseUrl + '/action/mobileData', JSON.stringify(params), function (res) {
            var response = JSON.parse(res)
            if (response.status == 'success') {
                Message.showmsg(response.message)
            } else {
                Message.showmsg(response.message)
            }
        })
    }






</script>
</body>

</html>
